In this lecture we will briefly show some examples of how you can compare two variables from a dataset. For these examples, you'll need the full control of ggplot instead of using qplot(), but we will show a quick example of what qplot is capable of. We'll use the built-in ggplot2 movies dataset:
library(ggplot2)
df <- movies
qplot(x=year, y=rating, data = df, geom = "density2d")
pl <- ggplot(movies,aes(x = year,y=rating))
pl + geom_bin2d()
# Control bin sizes
pl + geom_bin2d(binwidth=c(2,1))
pl + geom_density2d()
pl + geom_hex()
pl + geom_hex() + scale_fill_gradient(high='red',low='blue')
Alright that's it for the basics of plotting 2 variables against each other!